{
 "metadata": {
  "name": "recipes"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "IPython ActiveState Code Recipes magics"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "This is simple \"magic\" script for IPython. It let's user certain interface to ActiveState Code Recipes, from IPython console, Qt console, or if user wishes from Notebook ;)"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Trivial walk-trough:"
     ]
    },
    {
     "cell_type": "heading",
     "level": 4,
     "metadata": {},
     "source": [
      "1. Load recipes magic"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "If needed first install it with, i.e.:\n",
      "\n",
      "`%install_ext http://ipython-recipes-magic.googlecode.com/svn/trunk/recipes.py`"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Then load it:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%load_ext recipes"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\u001b[0;35m%lookup\u001b[0m <search term>\n",
        "\u001b[0;35m%fetch\u001b[0m  <idx|id>\n",
        "\u001b[0;35m%imply\u001b[0m  <idx|id>\n",
        "\u001b[0;35m%desc\u001b[0m   <idx|id>\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "As suggested 4 functions are exposed to user, for interaction."
     ]
    },
    {
     "cell_type": "heading",
     "level": 4,
     "metadata": {},
     "source": [
      "2. Recipes in action:"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "This is prepared infront, and is example where I have Excel file and need to read it in Python, so let's start by looking for ready made recipe.\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%lookup excel"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\u001b[0;35m 0:\u001b[0m class for writing content to excel and formatting  ...\n",
        "\u001b[0;35m 1:\u001b[0m format database field names in excel \n",
        "\u001b[0;35m 2:\u001b[0m using odbc for extracting data from ms excel \n",
        "\u001b[0;35m 3:\u001b[0m read tabular data from excel spreadsheets the fast ...\n",
        "\u001b[0;35m 4:\u001b[0m working with excel indexes \n",
        "\u001b[0;35m 5:\u001b[0m parsing excel xml \n",
        "\u001b[0;35m 6:\u001b[0m read tabular data from excel spreadsheets the fast ...\n",
        "\u001b[0;35m 7:\u001b[0m easy cross platform excel parsing with xlrd \n",
        "\u001b[0;35m 8:\u001b[0m simple conversion of excel files into csv and yaml ...\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Let's see what index 5 and 6 recipes offer:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%desc 5"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "This script parses an MS-Excel spreadsheet saved as XML.\n",
        "\n",
        "The spreadsheet:\n",
        "a1, b1\n",
        "a2, b2\n",
        "\n",
        "will be stored like this:\n",
        "\n",
        "[[u'a1', u'b1'], [u'a2', u'b2']]"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Not what I'm after, let's see description for next recipe:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%desc 6"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Sometimes you get an Excel spreadsheet (say, from the marketing departement) and you want to read tabular data from it (i.e. a line with column headers and lines of data). There are many ways to do this (including ODBC + mxODBC), but the easiest way I've found is this one : provide a file name and a sheet name, and read the data !"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Good. Let's review the code:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%fetch 6"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\u001b[1;34m\"\"\" This modules provides a lightweight API to access Excel data.\n",
        "    There are many ways to read Excel data, including ODBC. This module\n",
        "    uses ADODB and has the advantage of only requiring a file name and a\n",
        "    sheet name (no setup required).\n",
        "\"\"\"\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;32mimport\u001b[0m \u001b[0mwin32com\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclient\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;32mclass\u001b[0m \u001b[0mExcelDocument\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobject\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m    \u001b[1;34m\"\"\" Represents an opened Excel document.\n",
        "    \"\"\"\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;33m\n",
        "\u001b[0m    \u001b[1;32mdef\u001b[0m \u001b[0m__init__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mfilename\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnection\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mwin32com\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclient\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mDispatch\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'ADODB.Connection'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnection\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mOpen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;34m'PROVIDER=Microsoft.Jet.OLEDB.4.0;'\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;34m'DATA SOURCE=%s'\u001b[0m\u001b[1;33m%\u001b[0m\u001b[0mfilename\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;34m';Extended Properties=\"Excel 8.0;HDR=1;IMEX=1\"'\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;33m\n",
        "\u001b[0m    \u001b[1;32mdef\u001b[0m \u001b[0msheets\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;34m\"\"\" Returns a list of the name of the sheets found in the document.\n",
        "        \"\"\"\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mrecordset\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnection\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mOpenSchema\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m20\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mwhile\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mEOF\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mresult\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mFields\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mValue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mMoveNext\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mClose\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mdel\u001b[0m \u001b[0mrecordset\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;33m\n",
        "\u001b[0m    \u001b[1;32mdef\u001b[0m \u001b[0msheet\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mencoding\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mNone\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0morder_by\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;34m\"\"\" Returns a sheet object by name. Use sheets() to obtain a list of\n",
        "            valid names. encoding is a character encoding name which is used\n",
        "            to encode the unicode strings returned by Excel, so that you get\n",
        "            plain Python strings.\n",
        "        \"\"\"\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mreturn\u001b[0m \u001b[0mExcelSheet\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mencoding\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0morder_by\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;33m\n",
        "\u001b[0m    \u001b[1;32mdef\u001b[0m \u001b[0m__del__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclose\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;33m\n",
        "\u001b[0m    \u001b[1;32mdef\u001b[0m \u001b[0mclose\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;34m\"\"\" Closes the Excel document. It is automatically called when\n",
        "            the object is deleted.\n",
        "        \"\"\"\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnection\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mClose\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;32mdel\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnection\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mexcept\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;32mpass\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;32mdef\u001b[0m \u001b[0mstrip\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m    \u001b[1;34m\"\"\" Strip the input value if it is a string and returns None\n",
        "        if it had only whitespaces \"\"\"\u001b[0m\u001b[1;33m\n",
        "\u001b[0m    \u001b[1;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mbasestring\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mvalue\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstrip\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m==\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;32mreturn\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m\n",
        "\u001b[0m    \u001b[1;32mreturn\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;32mclass\u001b[0m \u001b[0mExcelSheet\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobject\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m    \u001b[1;34m\"\"\" Represents an Excel sheet from a document, gives methods to obtain\n",
        "        column names and iterate on its content.\n",
        "    \"\"\"\u001b[0m\u001b[1;33m\n",
        "\u001b[0m    \u001b[1;32mdef\u001b[0m \u001b[0m__init__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mdocument\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mencoding\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0morder_by\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdocument\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdocument\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mname\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0morder_by\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0morder_by\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mif\u001b[0m \u001b[0mencoding\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;32mdef\u001b[0m \u001b[0mencoder\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                \u001b[1;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0municode\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                    \u001b[0mvalue\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstrip\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                    \u001b[1;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m==\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                        \u001b[1;32mreturn\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                    \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                        \u001b[1;32mreturn\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mencode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mencoding\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                \u001b[1;32melif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mstr\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                    \u001b[0mvalue\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstrip\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                    \u001b[1;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m==\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                        \u001b[1;32mreturn\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                    \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                        \u001b[1;32mreturn\u001b[0m \u001b[0mvalue\u001b[0m \u001b[1;33m\n",
        "\u001b[0m                \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                    \u001b[1;32mreturn\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mencoding\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mencoder\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mencoding\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mstrip\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;33m\n",
        "\u001b[0m    \u001b[1;32mdef\u001b[0m \u001b[0mcolumns\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;34m\"\"\" Returns a list of column names for the sheet.\n",
        "        \"\"\"\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mrecordset\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mwin32com\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclient\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mDispatch\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'ADODB.Recordset'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mOpen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34mu'SELECT * FROM [%s]'\u001b[0m\u001b[1;33m%\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdocument\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnection\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;32mreturn\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mencoding\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfield\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mName\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mfield\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mFields\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mfinally\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mClose\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;32mdel\u001b[0m \u001b[0mrecordset\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                \u001b[1;33m\n",
        "\u001b[0m    \u001b[1;32mdef\u001b[0m \u001b[0m__iter__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;34m\"\"\" Returns a paged iterator by default. See paged().\n",
        "        \"\"\"\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpaged\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;33m\n",
        "\u001b[0m    \u001b[1;32mdef\u001b[0m \u001b[0mnaive\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;34m\"\"\" Returns an iterator on the data contained in the sheet. Each row\n",
        "            is returned as a dictionary with row headers as keys.\n",
        "        \"\"\"\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;31m# SLOW algorithm ! A lot of COM calls are performed.\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mrecordset\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mwin32com\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclient\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mDispatch\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'ADODB.Recordset'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0morder_by\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mOpen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34mu'SELECT * FROM [%s] ORDER BY %s'\u001b[0m\u001b[1;33m%\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0morder_by\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdocument\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnection\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mOpen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34mu'SELECT * FROM [%s]'\u001b[0m\u001b[1;33m%\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdocument\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnection\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;32mwhile\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mEOF\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                \u001b[0msource\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m{\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                \u001b[1;32mfor\u001b[0m \u001b[0mfield\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mFields\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                    \u001b[0msource\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mencoding\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfield\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mName\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mencoding\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfield\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mValue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                \u001b[1;32myield\u001b[0m \u001b[0msource\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mMoveNext\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mClose\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;32mdel\u001b[0m \u001b[0mrecordset\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mexcept\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;31m# cannot use \"finally\" here because Python doesn't want\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;31m# a \"yield\" statement inside a \"try...finally\" block. \u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mClose\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;32mdel\u001b[0m \u001b[0mrecordset\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;32mraise\u001b[0m\u001b[1;33m\n",
        "\u001b[0m    \u001b[1;33m\n",
        "\u001b[0m    \u001b[1;32mdef\u001b[0m \u001b[0mpaged\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mpagesize\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m128\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;34m\"\"\" Returns an iterator on the data contained in the sheet. Each row\n",
        "            is returned as a dictionary with row headers as keys. pagesize is\n",
        "            the size of the buffer of rows ; it is an implementation detail but\n",
        "            could have an impact on the speed of the iterator. Use pagesize=-1\n",
        "            to buffer the whole sheet in memory.\n",
        "        \"\"\"\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;31m# FAST algorithm ! It is about 10x faster than the naive algorithm\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;31m# thanks to the use of GetRows, which dramatically decreases the number\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;31m# of COM calls.\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[0mrecordset\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mwin32com\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclient\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mDispatch\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'ADODB.Recordset'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0morder_by\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mOpen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34mu'SELECT * FROM [%s] ORDER BY %s'\u001b[0m\u001b[1;33m%\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0morder_by\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdocument\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnection\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mOpen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34mu'SELECT * FROM [%s]'\u001b[0m\u001b[1;33m%\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdocument\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnection\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mfields\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mencoding\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfield\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mName\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mfield\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mFields\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[0mok\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mTrue\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;32mwhile\u001b[0m \u001b[0mok\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                \u001b[1;31m# Thanks to Rogier Steehouder for the transposing tip \u001b[0m\u001b[1;33m\n",
        "\u001b[0m                \u001b[0mrows\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mzip\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mGetRows\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpagesize\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                \u001b[1;33m\n",
        "\u001b[0m                \u001b[1;32mif\u001b[0m \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mEOF\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                    \u001b[1;31m# close the recordset as soon as possible\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                    \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mClose\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                    \u001b[0mrecordset\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                    \u001b[0mok\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mFalse\u001b[0m\u001b[1;33m\n",
        "\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                \u001b[1;32mfor\u001b[0m \u001b[0mrow\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrows\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                    \u001b[1;32myield\u001b[0m \u001b[0mdict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mzip\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfields\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmap\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mencoding\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mrow\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m        \u001b[1;32mexcept\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;32mif\u001b[0m \u001b[0mrecordset\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                \u001b[0mrecordset\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mClose\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\n",
        "\u001b[0m                \u001b[1;32mdel\u001b[0m \u001b[0mrecordset\u001b[0m\u001b[1;33m\n",
        "\u001b[0m            \u001b[1;32mraise\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Let's use it:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%imply 6"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\u001b[0;35mInfo:\u001b[0m  Recipe 6 imported as \"recipe\"."
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "dir(recipe)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 7,
       "text": [
        "['ExcelDocument',\n",
        " 'ExcelSheet',\n",
        " '__builtins__',\n",
        " '__doc__',\n",
        " '__name__',\n",
        " '__package__',\n",
        " 'strip',\n",
        " 'win32com']"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "ls *.xls"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Directory of C:\\Temp\n",
        "\n",
        "30.11.2012  14:03            56,832 h.xls\n",
        "               1 File(s)         56,832 bytes\n",
        "               0 Dir(s)  41,864,474,624 bytes free\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "x = recipe.ExcelDocument('h.xls')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 9
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print x.sheets()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "[u'h$']\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "h=[]\n",
      "for i in x.sheet('h$').paged(): h.append(i.values()[0])"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 11
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%pylab inline"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].\n",
        "For more information, type 'help(pylab)'.\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "hist(h, 32)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 13,
       "text": [
        "(array([ 13,  21,   5,   3,  28,  23,  24,  25,  26,  14,   8,   7,  15,\n",
        "        29,  53, 119, 145, 118, 136, 100,  75,  56,  38,  20,  22,  16,\n",
        "        14,  21,  15,  12,  16,   3]),\n",
        " array([  24360.,   27021.,   29682.,   32343.,   35004.,   37665.,\n",
        "         40326.,   42987.,   45648.,   48309.,   50970.,   53631.,\n",
        "         56292.,   58953.,   61614.,   64275.,   66936.,   69597.,\n",
        "         72258.,   74919.,   77580.,   80241.,   82902.,   85563.,\n",
        "         88224.,   90885.,   93546.,   96207.,   98868.,  101529.,\n",
        "        104190.,  106851.,  109512.]),\n",
        " <a list of 32 Patch objects>)"
       ]
      },
      {
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAD8CAYAAACW/ATfAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGP5JREFUeJzt3XlsVNfdxvFn7AHDeAPbVW0skiBwEhUIDSWg4JaMBERJ\nqrREVGoKJVQhYmsUCiIiqbqMlUrQxJSGEjZRliKBmgQIKEpCg8QFCgZKCNgJNe7CmgZje7wWG2zP\nff/wyxQHg2f1jOd8P5Kl8Z1rnx/n3vv4zOHMXIdt27YAAAktKdYFAACij7AHAAMQ9gBgAMIe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Zz9TXV1dTGuSFNJ1\nJXWM2gM91uEKt1+C7augKy4rK9Ply5c1a9YsSdL999+vsrIySR0dbNu2UlNT/S83JenGjRtyOBy6\nfv26f9v58+c1ePBgtbe3q729XZJ0/PhxjR49OtiSOhk6dKi+/vWv6/Dhw5I6LtaUlJSw6wzWvn37\n1NDQoHXr1mn//v3atm1bWH2Smpqq2tqOz83Yv3+/JkyYEHRNt8rPz1dubm5cHLtRo0aptLRUktTa\n2iqn0xnz4ydJR48e1ZgxYyR1vcR4zJgxYdUZrKqqKg0bNkySNGjQINXV1cVFP/3oRz/S/Pnz1adP\nH40bNy4uavL5fAFdQ8OGDdOZM2ckSSUlJXrkkUcCPtbh6unsDHrp5RtvvCGXy9VprujcuXO6dOmS\nrl+/runTpys/P18HDx7U0aNH1adPH02ePFkjRozQmTNntGPHDg0cOFAjR47UY489pi+//FLr1q1T\nbm6ucnNzNWXKlGDKkSSdPHlSR44cUd++fdXa2qqf/vSn+uMf/6iWlhY1NTVp/vz5Sk9P186dO0Ou\nMxxbtmzRE088obNnz4bcJ01NTSouLlZubq5cLpeee+65oOuorq7W9u3blZKSovr6ei1YsEDvv/9+\nTI/dTW+99ZYcDocaGxs1a9Ys7d69O+bH7/e//71mzZrlf0l/6xLjBQsWyOl0hnWeBauhoUGrVq1S\nbm6url69qhkzZuijjz6KaT81NTXpT3/6k9ra2lRQUKAnn3wy5tfeb3/7Wz333HN3vYb69++vmTNn\nqr29XcuWLVN2drba2tr04osvSgr8WAdb15IlS3TgwAH169dP48aNC6tfgr3+IrLOHgAQ3wz9PHsA\nMAthDwAGIOwBwACEPQAYgLAHAAMQ9gBgAMIeAAzwf5SUOaM2/8mUAAAAAElFTkSuQmCC\n"
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "---\n",
      "If user wants to review same lookup results, there is no need for searching again. `%lookup` function issued without arguments returns last query results:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%lookup"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\u001b[0;35m 0:\u001b[0m class for writing content to excel and formatting  ...\n",
        "\u001b[0;35m 1:\u001b[0m format database field names in excel \n",
        "\u001b[0;35m 2:\u001b[0m using odbc for extracting data from ms excel \n",
        "\u001b[0;35m 3:\u001b[0m read tabular data from excel spreadsheets the fast ...\n",
        "\u001b[0;35m 4:\u001b[0m working with excel indexes \n",
        "\u001b[0;35m 5:\u001b[0m parsing excel xml \n",
        "\u001b[0;35m 6:\u001b[0m read tabular data from excel spreadsheets the fast ...\n",
        "\u001b[0;35m 7:\u001b[0m easy cross platform excel parsing with xlrd \n",
        "\u001b[0;35m 8:\u001b[0m simple conversion of excel files into csv and yaml ...\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 4,
     "metadata": {},
     "source": [
      "3. Notes:"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Recipes can be referenced also by recipe ID instead index, in case user has the ID.\n",
      "\n",
      "All comunication is done with REST and JSON, except query which is tricky XML (XHTML), offered by none except Bing engine (thanks Microsoft, even Google doesn't offer that for free). So there is no HTML DOM or similar slowdowns for service not offered by AciteState as API, but it's designed for speed and instant results."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "For user conveniance there is also `_recipesmagics` dict object in user namespace, for possible introspecion"
     ]
    }
   ],
   "metadata": {}
  }
 ]
}